package com.lagou.ipersistence.reflection.invoker;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/**
 * 有些类里面有字段, 但是没有Setter方法, 这个Invoker提供了一种快捷为这类字段设置值得方法
 *
 * @author Yan Jiahong
 * Created on 2020/11/17
 */
public class SetFieldInvoker implements Invoker{
    private final Field field;

    public SetFieldInvoker(Field field) {
        this.field = field;
    }

    @Override
    public Object invoke(Object target, Object[] args) throws IllegalAccessException, InvocationTargetException {
         field.set(target, args[0]);
         return null;
    }

    @Override
    public Class<?> getType() {
        return null;
    }
}
